﻿using Ec_System.Models.Web;
using Ec_System.Service.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ec_System.Bll.Web
{
    /// <summary>
    /// 本类主要提供给ProductInfo使用
    /// </summary>
    public class VendorShopManager
    {
        VendorShopService vendorShopService = new VendorShopService();
        PromotionScheduleService promotionScheduleService = new PromotionScheduleService();
      
        // <summary>
        /// 根据商品ID获取其附属信息,店铺信息等
        /// </summary>
        /// <param name="productID"></param>
        /// <returns></returns>
        public ShopProductData GetProductInfoByID(int productID)
        {
            ShopProductData product = new ShopProductData();
            //基础信息
            product = vendorShopService.GetProductInfoByID(productID);
            //本店销量前5名
            product.ShopProductTop5 = vendorShopService.GetShopTop5ByShopID(product.ShopId);
            //到促销表查询信息,主要用于在View判断是否为空从而切换正常或抢购页面
            product.PromotionSchedule = promotionScheduleService.GetPromotionScheduleByProductID(product.ProductID);

            return product;
        }

        // <summary>
        /// 获取店铺列表--带分页
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public VendorShopResponseData GetShopListWithPage(int pageIndex, int pageSize)
        {
            return vendorShopService.GetShopListWithPage(pageIndex, pageSize);
        }

        /// <summary>
        /// 根据店铺ID获取其详情
        /// </summary>
        /// <param name="shopID"></param>
        /// <returns></returns>
        public VendorShopData GetShopDetailByID(int shopID)
        {
            return vendorShopService.GetShopDetailByID(shopID);
        }
    }
}
